package com.xiyue.leaspring.datasourceTest;

import java.util.Date;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

@ContextConfiguration(locations = {"classpath:spring/spring-jdbc5.xml"})
@RunWith(SpringJUnit4ClassRunner.class)//设置要测试的工具
public class DataSourceTest5 {
	
	private Logger logger = LoggerFactory.getLogger(DataSourceTest5.class);
	
	@Autowired
	private JdbcTemplate jdbcTemplate;
		
	@Test
	public void testDataSource() throws Exception {
		
		String sql = "update news set title=?,pubdate=?,note=?,price=?,readcount=? "
				+ "WHERE nid=?";
		String title = "阿斯顿xxxxxxxxxxxxxxxxxx";
		Date pubDate = new Date();
		String note = "很好的品牌哈哈xxxxxxxxxxxxxxxx";
		double price = 123210.0;
		int readcount = 562143;
		long nid = 3;
		int len = this.jdbcTemplate.update(sql,title,pubDate,note,price,readcount,nid);//数据更新操作
		this.logger.info("更新行数："+len);
		
	}

}
